package com.zcoj.pojo.Vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Objects;

/**
 * @author chenbin
 * @version 1.0
 * @description: TODO
 * @date 2023/5/9 08:39
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ContestRankVO {
    private Integer uid;
    private String username;
    private String realname;
    private Long sumTime;
    private Integer sumScore;
    List<ContestRankSingleProblemInfoVO> contestRankSingleProblemInfoVOS;

    public void setContestRankSingleProblemInfos(List<ContestRankSingleProblemInfoVO> contestRankSingleProblemInfoVOS){
        this.contestRankSingleProblemInfoVOS=contestRankSingleProblemInfoVOS;
        Long tempSumTime=0L;
        Integer tempSumScore=0;
        for (ContestRankSingleProblemInfoVO contestRankSingleProblemInfoVO : contestRankSingleProblemInfoVOS) {
            //
            if( Objects.nonNull(contestRankSingleProblemInfoVO.getConsumeTime())){
                tempSumTime+=contestRankSingleProblemInfoVO.getConsumeTime();
            }
            if(Objects.nonNull(contestRankSingleProblemInfoVO.getScore())){
                tempSumScore+=contestRankSingleProblemInfoVO.getScore();
            }
        }
        this.sumTime=tempSumTime;
        this.sumScore=tempSumScore;
    }
}
